#ifndef GPS_PARSE_H
#define GPS_PARSE_H

#ifdef __cplusplus
extern "C" {
#endif

///////////////// gps ///////////////////
// 1 minute latitude 1853m
// 1 minute longitude 1418m
#define LAT100K_TO_METER 0.01853
#define LON100K_TO_METER 0.01418

// take two lat or lon points in 10K minute format
// and return difference in meters
#define diff_lat_meters(a,b) (((kal_t)(a-b))*LAT100K_TO_METER) 
#define diff_lon_meters(a,b) (((kal_t)(a-b))*LON100K_TO_METER)
	
// take difference of lat or lon and convert to meters
#define lat_to_meters(a) (((kal_t)a)*LAT100K_TO_METER)
#define lon_to_meters(a) (((kal_t)a)*LON100K_TO_METER)

typedef struct {
  volatile int32_t latitude;
  volatile int32_t longitude;
  volatile int8_t fix;
  volatile int8_t nsatellites;
  volatile int8_t hdop;

  int8_t w_fix;
  int8_t w_nsatellites;
  int8_t w_hdop;
  int32_t w_lat;
  int32_t w_lon;
  uint32_t id;

  uint32_t state;
} gps_t;

void gps_init(gps_t* gps);
void gps_encode(char c, gps_t* gps);

#ifdef __cplusplus
}
#endif

#endif
